<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
      <link rel="stylesheet" href="../../static/css/font.css" th:href="@{/css/font.css}">
      <link rel="stylesheet" href="../../static/css/xadmin.css" th:href="@{/css/xadmin.css}">
      <script src="../../static/js/jquery-3.2.1.min.js" type="text/javascript" th:src="@{/js/jquery-3.2.1.min.js}"></script>
      <script src="../../static/js/vue.js" type="text/javascript" th:src="@{/js/vue.js}"></script>
      <script src="../../static/lib/layui/layui.js" charset="utf-8" th:src="@{/lib/layui/layui.js}"></script>
      <script type="text/javascript" src="../../static/js/xadmin.js" th:src="@{/js/xadmin.js}"></script>


      <link rel="stylesheet" th:href="@{/lib/layui/css/layui.css}">
      <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}">
      <script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
    <div class="x-body">
        <form class="layui-form">

            <div class="layui-form-item">
                <label for="quContent" class="layui-form-label">
                    <span class="x-red"></span>试题内容
                </label>
                <div class="layui-input-inline">
                    <textarea id="quContent" name="quContent" required lay-verify="required" placeholder="请输入" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quAoption" class="layui-form-label">
                    <span class="x-red"></span>A:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quAoption" name="quAoption" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quBoption" class="layui-form-label">
                    <span class="x-red"></span>B:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quBoption" name="quBoption" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quCoption" class="layui-form-label">
                    <span class="x-red"></span>C:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quCoption" name="quCoption" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quDoption" class="layui-form-label">
                    <span class="x-red"></span>D:
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quDoption" name="quDoption" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label for="quType" class="layui-form-label">
                    <span class="x-red"></span>类型:
                </label>
                <div class="layui-input-inline">
                    <select id="quType" name="quType" >
                        <option disabled selected>请选择题型</option>
                        <option value="单选题">单选题</option>
                        <option value="多选题">多选题</option>
                        <option value="判断题">判断题</option>
                    </select>
                </div>
            </div>


            <div class="layui-form-item">
                <label for="quScore" class="layui-form-label">
                    <span class="x-red"></span>分数
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quScore" name="quScore" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="quAnswer" class="layui-form-label">
                    <span class="x-red"></span>答案
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="quAnswer" name="quAnswer" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="subId" class="layui-form-label">
                    <span class="x-red"></span>科目
                </label>
                <div class="layui-input-inline">
                    <select name="subId" id="subId">
                        <option th:each="subject:${subjects}" th:value="${subject.subId}" th:text="${subject.subName}">
                        </option>
                    </select>
                </div>
            </div>


          <div class="layui-form-item">
              <label for="subId" class="layui-form-label">
              </label>
              <button  class="layui-btn" lay-filter="add" lay-submit="">
                  增加
              </button>
          </div>
      </form>
    </div>
    <script>
        layui.use(['form','layer'], function(){
            $ = layui.jquery;
          var form = layui.form
          ,layer = layui.layer;
        


          //监听提交
          form.on('submit(add)', function(data){
            console.log(data);
            $.ajax({
                url:'/qubank/addqu',
                dataType:'json',
                type:'post',
                data:data.field,
                success:function (rs) {
                    if (rs.code == 200){
                        layer.alert(rs.msg, {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //刷新
                            parent.window.loadData();
                        });
                    }else {
                        layer.open({
                            title: '添加考生信息'
                            ,content: '添加失败!2333333'
                        });
                    }
                },error:function () {
                    layer.open({
                        title: '系统消息'
                        ,content: '服务器错误!'
                    });
                }
            });

            return false;
          });
          
          
        });
    </script>



  </body>

</html>